package com.ljx.recruitment.user.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ljx.recruitment.user.constant.IntegrationAvatarConstant;
import com.ljx.recruitment.user.typehandler.TenantResumeTypeHandler;
import com.ljx.recruitment.user.typehandler.details.ResumeDetails;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomUtils;

import java.util.Date;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-10-12  15:22
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("tb_user")
public class User {

    private Long id;

    private String avatar;

    private String nickname;

    private String username;

    private String password;

    private String email;

    private String phone;

    private String introduce;

    private Long tenantId;

    private String recommendCode;

    @TableField(typeHandler = TenantResumeTypeHandler.class)
    private ResumeDetails resumeDetails;

    private Date createTime;

    private Date updateTime;

    private Integer status;

    private Integer ver;

    public User(String username, String password, Long tenantId) {
        this.username = username;
        this.password = password;
        this.tenantId = tenantId;
        this.nickname = "用户" + RandomUtils.nextInt();
        this.avatar = IntegrationAvatarConstant.getAvatarByName(this.nickname);
    }
}
